package serializer

import "monitoring-api/models"

// AreaData 基础列表结构
type AreaData struct {
	Area []int `json:"area"`
}

type BrowserData struct {
	Browser []int `json:"browser"`
}

type LogsList struct {
	Total int64       `json:"total"`
	Page  int64       `json:"page"`
	Size  int64       `json:"size"`
	Logs  interface{} `json:"logs"`
}

type GraphDataResponse struct {
	Err     [][]int64 `json:"err"`
	Per     [][]int64 `json:"per"`
	User1   [][]int64 `json:"user1"`
	User2   [][]int64 `json:"user2"`
	Http1   [][]int64 `json:"http1"`
	Http2   [][]int64 `json:"http2"`
	Browser []int64   `json:"browser"`
	Area    []int64   `json:"area"`
}

// BuildAreaResponse 序列化用户地区结构
func BuildAreaResponse(area []int) Response {
	return Response{
		Code: 0,
		Data: AreaData{
			Area: area,
		},
		Message: "获取用户地区分布信息成功",
	}
}

// BuildBrowserResponse 序列化用户浏览器使用类型结构
func BuildBrowserResponse(browser []int) Response {
	return Response{
		Code: 0,
		Data: BrowserData{
			Browser: browser,
		},
		Message: "获取用户浏览器使用类型信息成功",
	}
}

func BuildErrorsResponse(logs []models.Error, total int64, page int64) Response {
	return Response{
		Code: 0,
		Data: LogsList{
			Logs:  logs,
			Total: total,
			Page:  page,
			Size:  10,
		},
		Message: "获取异常日志信息成功",
	}
}

func BuildActionsResponse(logs []models.UserAction, total int64, page int64) Response {
	return Response{
		Code: 0,
		Data: LogsList{
			Logs:  logs,
			Total: total,
			Page:  page,
			Size:  10,
		},
		Message: "获取用户行为日志信息成功",
	}
}

func BuildReqResponse(logs []models.Req, total int64, page int64) Response {
	return Response{
		Code: 0,
		Data: LogsList{
			Logs:  logs,
			Total: total,
			Page:  page,
			Size:  10,
		},
		Message: "获取请求日志信息成功",
	}
}

func BuildPerResponse(logs []models.Per, total int64, page int64) Response {
	return Response{
		Code: 0,
		Data: LogsList{
			Logs:  logs,
			Total: total,
			Page:  page,
			Size:  10,
		},
		Message: "获取请求日志信息成功",
	}
}
